<?php

namespace app\exam\validate;

use think\Validate;

/**
 * 公开考试练习验证
 */
class Paper extends Validate
{
    /**
     * 定义验证规则
     * 格式：'字段名'    =>    ['规则1','规则2'...]
     *
     * @var array
     */
    protected $rule = [
        'module_id'     => 'require|number',
        'category'      => 'number',
        'title'         => 'require',
        'paper_id'      => 'require|number',
        'rollup_id'     => 'require|number',
        'part_id'       => 'require|number',
        'topic_id'      => 'require|/^[\d,]+$/',
        'topic_level'   => 'require|in:1,2',
        'is_right'      => 'require|in:0,1',
        // 'answer_data'   => 'require',
        'unique_code'   => 'require',
        'time_takes'    => 'require',

    ];

    protected $field = [
        'module_id'     => '版块',
        'title'         => '名称',
        'paper_id'      => '试卷',
        'rollup_id'     => '套卷',
        'topic_id'      => '试题',
        'topic_level'   => '试题层级',
        'is_right'      => '试题答案结果',
        // 'answer_data'   => '答案',
        'unique_code'   => '唯一标识',
        'time_takes'    => '考试用时',
    ];

    /**
     * 定义错误信息
     * 格式：'字段名.规则名'    =>    '错误信息'
     *
     * @var array
     */
    protected $message = [
    ];

    /**
     * 验证场景
     */
    protected $scene = [
        'paper_category'        => ['module_id'],
        'paper_base'            => ['paper_id'],
        'rollup_paper_base'     => ['rollup_id', 'paper_id'],
        'paper_topic'           => ['topic_id' , 'paper_id'],   //, 'part_id'
        'paper_answer'          => ['paper_id', 'unique_code', 'time_takes'],//'answer_data',
        'rollup_paper_answer'   => ['rollup_id', 'paper_id','unique_code', 'time_takes'],//'answer_data',
    ];


}
